package core.report.yearReport.bean;

import org.springframework.jdbc.support.rowset.SqlRowSet;

import core.report.yearReport.util.ExportExcelUtil;

public class Itemsalerank extends BaseExcelReportDataBean {
	private String name;

	private String pro_code;
	private String brand_name;
	private String year;
	private String sort_name;
	private double L_total_pieces;
	private double total_pieces;
	private double C_total_pieces;
	private double sell_price;
	private double retail_price;
	private double gross_per;
	
	public Itemsalerank() {
	}

	public Itemsalerank(SqlRowSet rs) {
		this.pro_code = rs.getString("pro_code");
		this.brand_name = rs.getString("brand_name");
		this.year = rs.getString("year");
		this.sort_name = rs.getString("sort_name");
		this.L_total_pieces = rs.getDouble("L_total_pieces");
		this.total_pieces = rs.getDouble("total_pieces");
		this.C_total_pieces = rs.getDouble("C_total_pieces");
		this.sell_price = rs.getDouble("sell_price");
		this.retail_price = rs.getDouble("retail_price");
		this.gross_per = rs.getDouble("gross_per");
		
		this.name = this.pro_code;
	}

	public void addProperties(Itemsalerank data) {
		this.setL_total_pieces(this.getL_total_pieces()+data.getL_total_pieces());
		this.setTotal_pieces(this.getTotal_pieces()+data.getTotal_pieces());
		this.setC_total_pieces(this.getC_total_pieces()+data.getC_total_pieces());
		this.setSell_price(this.getSell_price()+data.getSell_price());
		this.setRetail_price(this.getRetail_price()+data.getRetail_price());
		this.setGross_per(this.getGross_per()+data.getGross_per());
	}

	public void subtract(int size) {
		if (size != 0) {
			this.setC_total_pieces(this.getC_total_pieces()/size);
			this.setSell_price(this.getSell_price()/size);
			this.setRetail_price(this.getRetail_price()/size);
			this.setGross_per(this.getGross_per()/size);
		} else {
			this.setC_total_pieces(0);
			this.setSell_price(0);
			this.setRetail_price(0);
			this.setGross_per(0);
		}
	}

	@Override
	public int getFormatTypeByIndex(int index) {
		switch (index) {
		case 0:
			return ExportExcelUtil.TEXT_TYPE;
		case 1:
			return ExportExcelUtil.TEXT_TYPE;
		case 2:
			return ExportExcelUtil.TEXT_TYPE;
		case 3:
			return ExportExcelUtil.TEXT_TYPE;
		case 4:
			return ExportExcelUtil.DECIMAL_TYPE;
		case 5:
			return ExportExcelUtil.DECIMAL_TYPE;
		case 6:
			return ExportExcelUtil.PERCENT_TYPE;
		case 7:
			return ExportExcelUtil.PERCENT_TYPE;
		case 8:
			return ExportExcelUtil.PERCENT_TYPE;
		case 9:
			return ExportExcelUtil.PERCENT_TYPE;
		default:
			return ExportExcelUtil.TEXT_TYPE;
		}
	}

	@Override
	public String getValueByIndex(int index) {
		String value = "";
		switch (index) {
		case 0:
			value = this.getName();
			break;
		case 1:
			value = this.getBrand_name();
			break;
		case 2:
			value = this.getYear()+"";
			break;
		case 3:
			value = this.getSort_name();
			break;
		case 4:
			value = this.getL_total_pieces() + "";
			break;
		case 5:
			value = this.getTotal_pieces() + "";
			break;
		case 6:
			value = this.getC_total_pieces()+ "";
			break;
		case 7:
			value = this.getSell_price() + "";
			break;
		case 8:
			value = this.getRetail_price() + "";
			break;
		case 9:
			value = this.getGross_per()+ "";
			break;
		}
		return value;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPro_code() {
		return pro_code;
	}

	public void setPro_code(String pro_code) {
		this.pro_code = pro_code;
	}

	public String getBrand_name() {
		return brand_name;
	}

	public void setBrand_name(String brand_name) {
		this.brand_name = brand_name;
	}

	public String getYear() {
		return year;
	}

	public void setYear(String year) {
		this.year = year;
	}

	public String getSort_name() {
		return sort_name;
	}

	public void setSort_name(String sort_name) {
		this.sort_name = sort_name;
	}

	public double getL_total_pieces() {
		return L_total_pieces;
	}

	public void setL_total_pieces(double l_total_pieces) {
		L_total_pieces = l_total_pieces;
	}

	public double getTotal_pieces() {
		return total_pieces;
	}

	public void setTotal_pieces(double total_pieces) {
		this.total_pieces = total_pieces;
	}

	public double getC_total_pieces() {
		return C_total_pieces;
	}

	public void setC_total_pieces(double c_total_pieces) {
		C_total_pieces = c_total_pieces;
	}

	public double getSell_price() {
		return sell_price;
	}

	public void setSell_price(double sell_price) {
		this.sell_price = sell_price;
	}

	public double getRetail_price() {
		return retail_price;
	}

	public void setRetail_price(double retail_price) {
		this.retail_price = retail_price;
	}

	public double getGross_per() {
		return gross_per;
	}

	public void setGross_per(double gross_per) {
		this.gross_per = gross_per;
	}
}
